package com.freewater.springboot.demo.ioc.lookupmethodinject.servicelocator;

import com.freewater.springboot.demo.ioc.lookupmethodinject.Command;

public class CommandManager {

    private final CommandFactory commandFactory;

    public CommandManager(CommandFactory commandFactory) {
        this.commandFactory = commandFactory;
    }

    public void process(Object commandState) {
        // 使用工厂方法查询bean
        final Command command = commandFactory.getCommand("asyncCommand");
        command.setState(commandState);
        command.execute();
    }
}
